var async = require("async");
var renderEngin = require("../common/renderEngin");
var Tools = require("../common/tools");
exports.address = function(req, res) {
    use(["public/javascripts/address/init.js", "public/javascripts/service/addressService.js"], function(PageComponent, addressService) {
        var type = req.param("type") || "receive", transportType = 11;
        var apiMethod = null;
        var storage = {};
        storage["slider"] = Tools.getPageSliderData("user_center");
        storage["typeName"] = type;
        
        PageComponent = React.createFactory(PageComponent);
        if(type == 'send') {
            type = 1;
            apiMethod = addressService.searchReceiveAddress;
        }else if(type == "receive") {
            type = 2;
            apiMethod = addressService.searchReceiveAddress;
        } else if(type == "pick"){
            type = 3;
            apiMethod = addressService.searchReceiveAddress;
            transportType = "";
        }
        apiMethod({headers: req.headers, urlParams: {"type": type, "transportType": transportType}}, function(result) {
            storage["address"] = result.data;
            renderEngin.call(res, 'address', PageComponent, storage);
        });
    });
}
